#include <iostream>
using namespace std;
int n,m,p;
const int N=5010;
int fa[N];
int find(int x)
{
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}
int x,y;
int main()
{
	cin>>n>>m>>p;
   for(int i=1;i<=n;i++)fa[i]=i;
	while(m--)
	{
		cin>>x>>y;
		int fx=find(x);
		int fy=find(y);
		fa[fx]=fy;
	}
	while(p--)
	{
		cin>>x>>y;
		if(find(x)==find(y))
		cout<<"YES"<<endl;
		else 
		cout<<"NO"<<endl;
	}
	return 0;
}
